import type { ResponeData } from "@/types/HttpType";

import { env } from "@/utils/env";
import http from "./http";


export const uploadFile = async (
  data: any,
  onUploadProgress: Function,
  source?: any
): Promise<string> => {
  let res = await http<string>({
    url: env.VITE_JIANCAI + "/file/upload",
    method: "post",
    data,
    headers: {
      "Content-Type": "multipart/form-data",
    },
    cancelToken: source?.token,
    // cancelToken: new CancelToken(function executor(c) {
    //     // 保存cancel函数以便后续调用

    //     cancel = c;

    //     window.luqiCancel = c
    //   }),
    onUploadProgress: (e) => {
      onUploadProgress(e);
    },
  });

  return res.data;
};
 